package com.zhs.study.task;

import com.zhs.study.pojo.Data;
import lombok.extern.slf4j.Slf4j;

import java.util.HashSet;
import java.util.Set;
import java.util.concurrent.locks.ReentrantLock;

/**
 * @author zhenghuisheng
 * @date : 2023/3/22
 */

@Slf4j
public class Task implements Runnable {

    public int i;
    public int j;
    Data data = null;

    public Task(Data data){
        this.data = data;
    }

    //run方法中写具体要干的事情，如上传文件，异步消费等
    @Override
    public void run() {
        try{
            String name = Thread.currentThread().getName();
            log.info(name + "已经获取到锁锁");
            log.info("==========当前线程名称为：" + name + "：当前值为：" + (data.getI()));
            log.info(name + "将要释放锁");
            Thread.sleep(1000000);
        }catch (Exception e){
            e.printStackTrace();
        }
    }

}

